package ma.fizazi.missionsmanagement.business.profils.impl;

import java.util.List;

import ma.fizazi.missionsmanagement.business.profils.ProfilBusiness;
import ma.fizazi.missionsmanagement.dao.commons.DAOServices;
import ma.fizazi.missionsmanagement.model.Profil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("profilBusiness")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class ProfilBusinessImpl implements ProfilBusiness {

	@Autowired
	DAOServices daoServices;

	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void saveProfil(Profil profil) {
		daoServices.saveEntity(profil);
	}

	public Profil getProfilById(int id) {
		return (Profil) daoServices.getEntityById2(Profil.class, new Integer(id));
		
	}

	public Profil getProfilByNumber(int number) {
		return (Profil) daoServices.getUniqueEntitiyByProperty(Profil.class, "num", number);
	}

	public List<Profil> getAllProfils() {
		return daoServices.getEntities(Profil.class);
	}

}
